<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>充值积分_资源共享平台</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
</head>
<body>
<div style="padding: 20px">
    <form class="layui-form" method="post">
        <input type="hidden" name="id" th:value="${id}" />
        <div class="layui-form-item">
            <label class="layui-form-label">充值积分：</label>
            <div class="layui-input-block">
                <input type="text" name="points" class="layui-input" lay-verify="required|number" lay-reqText="请输入充值积分"/>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="*">提交</button>
                <label id="errorInfo" style="color: red;"></label>
            </div>
        </div>
    </form>
</div>

<script src="/layui/layui.js"></script>
<script src="/js/common.js"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    layui.use(['layer', 'form'], function () {
        let $ = layui.jquery,
            layer = layui.layer,
            form = layui.form;

        // 监听提交
        form.on('submit(*)', function (data) {
            $.post("/admin/user/addPoints", data.field, function (result) {
                if (result.success) {
                    layer.alert("积分充值成功！", function () {
                        layer.close();
                        refreshParentTable("userListTable");
                    });
                } else {
                    $("#errorInfo").text(result.errorInfo);
                }
            }, "json");
            return false;
        });
    });
    /*]]>*/
</script>
</body>
</html>